<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%-- 
    JSP Name : ml_100_05.jsp
    Description : 뉴스레터 등록
    author Ki min
    since 2012. 7. 24.
    version 1.0
    Modification Information
       since          author              description
    ===========    =============    ===========================
    2012. 7. 24.     Ki min     최초 생성
--%>
<%@ include file="/WEB-INF/jsp/co/mn/include/declare.jspf" %>
<%@ include file="/WEB-INF/jsp/co/mn/include/session.jspf" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ko" lang="ko">
<head>
<%@ include file="/WEB-INF/jsp/co/mn/include/header.jspf" %>
<script type="text/javaScript" language="javascript">
$(document).ready(function() {    
   
    /* form validation check */
    onloadCharCheck();
   
    /* List Page 이동 */
    $("#listButn").bind("click", moveListPage);
    /* Form Submit */
    $("#rgstButn").bind("click", blcSubm);
    /* Form 초기화 */
    $("#cnclButn").bind("click", formIniz);
    /* 이미지 추가  */
    $("#imgButn").bind("click", addImage);
});
/*
 * 리스트페이지 이동
 */
function moveListPage() {
    $("#hiddenForm").attr('action','/ml_100_03.do').submit();
}

/*
 * Form Submit
 */
function blcSubm() {
    if (!validateForm($("#mainForm"))) {
        return;
    }
    if (!isSchrChk($("#attcFile").val())) {
        alert("[제목] 은 특수문자(!#$%^&*|'<>-;)를 입력할 수 없습니다.");
        $("#attcFile").focus();
        return;
    }
    
    $("#mainForm").attr('target','comIframe');
    $("#mainForm").attr('action','/ml_100_07.do');
    $("#mainForm").submit();
}

/*
 * 이미지 추가
 */
 function addImage() {
     if ( $("#attcFile").val()=="" ) {
         alert("추가할 파일이 없습니다.");
         $("#attcFile").focus();
         return;
     } 
     $("#mainForm").attr('target','imgIframe');
     $("#mainForm").attr('action','/ml_100_09.do').submit();
     
 }
 
/*
 * 이미지 리스트 추가
 */
 var addFileNmArry = "";
 function addHtml(filNm) {
     var addHtmlrow = "<tr><td><img width='100' src='/upfile/image/"+filNm+"' /></td><td>image</td><td>${hostUrl}/upfile/image/"+filNm+"</td></tr>";
     
     $("#imgTbl tbody").append(addHtmlrow);
     addFileNmArry = addFileNmArry + "," + filNm;
     $("#addFileNmArry").val(addFileNmArry);
     mainForm.attcFile.select();
     document.execCommand('Delete');
}
 
 /*
  * Form 초기화
  */
 function formIniz() {
     $("form").each(function(){
        this.reset(); 
     });
     addHtmlText = "";
     $("#imgIframe").attr('src', "/ml_100_06.do");
 }

</script>
</head>
<body>
<div id="wrap">
    <!-- top -->
    <%@ include file="/WEB-INF/jsp/co/mn/include/top.jsp" %>
    <!-- top -->

    <!-- container -->
    <div id="container">
        <!-- LNB -->
        <%@ include file="/WEB-INF/jsp/co/mn/include/left.jsp" %>
        <!-- LNB -->
        
        <div id="contents" class="clearfix">
        
            <!-- location -->
            <%@ include file="/WEB-INF/jsp/co/mn/include/location.jsp" %>
            <!-- location -->
            <form id="hiddenForm" name="hiddenForm" method="post">
                <input type="hidden" id="ltrIdx" name="blbIdx" value="${result.blbIdx }" />
                <input type="hidden" id="currentPageNo" name="currentPageNo" value="${rqInfo.currentPageNo }" />
                <input type="hidden" id="srchScn" name="srchScn" value="${rqInfo.srchScn }" />
                <input type="hidden" id="srchTxt" name="srchTxt" value="${rqInfo.srchTxt }" />
            </form>
            <form id="mainForm" name="mainForm" method="post" enctype="multipart/form-data">
            <table border="1" class="frmTable" summary="뉴스레터 관리의 제목,내용이 기재 되어 있는 표">
                <col width="25%" />
                <col width="75%" />
                <tbody>
                    <input type="hidden" id="ltrIdx" name="ltrIdx" value="${rqInfo.ltrIdx}" />
                    <input type="hidden" id="currentPageNo" name="currentPageNo" value="${rqInfo.currentPageNo }" />
                    <input type="hidden" id="srchScn" name="srchScn" value="${rqInfo.srchScn }" />
                    <input type="hidden" id="srchTxt" name="srchTxt" value="${rqInfo.srchTxt }" />
                    <input type="hidden" id="addFileNmArry" name="addFileNmArry"  />
                    <tr>
                        <th>제목</th>
                        <td><input type="text" maxlength="100" id="title" name="title" title="제목" nullable="true" minbyte="2" /></td>
                    </tr>
                    <tr>
                        <th>&nbsp;</th>
                        <td class="newsAdd">
                            <div class="imgDesc">
                                <p>* 이미지를 먼저 등록하시고 HTML 소스를 등록해주세요.</p>
                                <p>* 이미지 및 HTML 등록시 반드시 파일명 뒷부분에 날짜를 포함해주세요. <span>예) csr_img_120801.jpg 또는 csr_news_120801.html</span></p>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <th>연도/월</th>
                        <td>  
                            <select id="rgstY" name="rgstY" >
                                <option value="${cDate }">${cDate }년</option>
                                <option value="${cDate + 1}">${cDate + 1}년</option>
                                <option value="${cDate + 2}">${cDate + 2}년</option>
                            </select>
                            <select id="rgstM" name="rgstM"  >
                                <option value="1">1월</option>
                                <option value="2">2월</option>
                                <option value="3">3월</option>
                                <option value="4">4월</option>
                                <option value="5">5월</option>
                                <option value="6">6월</option>
                                <option value="7">7월</option>
                                <option value="8">8월</option>
                                <option value="9">9월</option>
                                <option value="10">10월</option>
                                <option value="11">11월</option>
                                <option value="12">12월</option>
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <th>이미지</th>
                        <td>
                            <div class="imgUpload">
                                <p class="add file"><input type="file" id="attcFile" name="attcFile" size="26" /><input type="image" onclick="addImage(); return false;" src="/img/mng/btn/btn_file_add.gif" alt="추가" title="추가" /></p>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <th>HTML</th>
                        <td>
                            <div class="imgUpload">
                                <p><input type="file" size="26" id="htmlFile" name="htmlFile" nullable="true" title="html파일"/></p>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <th>첨부 이미지</th>
                        <td>
                            <div class="atcList">
                                <table border="0" id="imgTbl">
                                    <col width="30%" />
                                    <col width="15%" />
                                    <col width="55%" />
                                    <thead>
                                        <tr>
                                            <th>미리보기</th>
                                            <th>path</th>
                                            <th class="src">경로</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                    </tbody>
                                </table>
                            </div>
                            <iframe name="imgIframe" id="imgIframe" width="0" height="0"></iframe>
                        </td>
                    </tr>
                </tbody>
            </table>
            </form>
            <div class="btnBoard">
                <span class="flow">
                    <a id="listButn" href="#">목록</a>
                </span>
                <span class="reverse">
                    <input type="submit" id="rgstButn" name="rgstButn" title="등록" value="등록" />
                    <input type="submit" id="cnclButn" name="cnclButn" title="취소" value="취소" />
                </span>
            </div>
        </div>
    </div>
    <!-- /container -->

    <!-- footer -->
    <%@ include file="/WEB-INF/jsp/co/mn/include/bottom.jsp" %>
    <!-- /footer -->
</div>
</body>
</html>